package com.bhcj.telling.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhcj.telling.R;
import com.bhcj.telling.model.bean.GuaWords;

import java.util.List;

public class GuaAdapter extends ArrayAdapter<GuaWords.Entity> {
    public GuaAdapter(@NonNull Context context, int resource, @NonNull List<GuaWords.Entity> objects) {
        super(context, resource, objects);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        GuaWords.Entity entity = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.gua_item, parent, false);
        TextView name = view.findViewById(R.id.entity_name);
        TextView text = view.findViewById(R.id.entity_text);
        name.setText(entity.getName()+"：");
        text.setText(entity.getText());
        return view;
    }
}
